package com.myWeb.controller;

import com.myWeb.dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String userName,password;
        UserDao dao = new UserDao();
        int result = 0;
        request.setCharacterEncoding("utf-8");
        userName = request.getParameter("userName");
        password = request.getParameter("password");
        result = dao.login(userName,password);
        if(result == 0){
            response.sendRedirect("/myWeb/error.html");
        }else{
            request.getSession();
            response.sendRedirect("/myWeb/main.html");
        }



    }


}
